package tools;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;


public class TimeConver {

	
	// Date to String：  
	public static String DatetoString(Date someDate, String template) {  
		    if(someDate == null)		
		    	return "";  
		    SimpleDateFormat formatter = new SimpleDateFormat(template);  
		    String dateString = formatter.format(someDate);  
		    return dateString;  
	}    
		  
	// String to Date 用template限制时间字符串的格式，如yyyy-MM-dd HH:mm:ss  
	public static Date StringtoDate(String input, String template) throws ParseException {  
	      DateFormat df = new SimpleDateFormat(template);  
	      Date date = new Date();  
	        
	          date = df.parse(input);  
	    
	      return date;  
	}   




}
